package com.example.demo.controller;


import com.example.demo.pojo.Journal;
import com.example.demo.service.JournalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/journal")
public class JournalController {

    @Autowired
    private JournalService journalService;

    @GetMapping("getJournal")
    public ResponseEntity<?> getJournals() {
        List<Journal> jou = journalService.findAll();
        int size = jou.size();
        Map<String, Object> response = new HashMap<>();
        response.put("total", size); // 总条目数
        response.put("items", jou); // 当前页的数据

        return ResponseEntity.ok(response);
    }


}
